package com.bloveoa.zkkd.repository;

import com.bloveoa.zkkd.doman.BoxInfoModel;
import com.bloveoa.zkkd.doman.OutTokenModel;
import org.hibernate.sql.Update;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface BoxInfoRepository extends JpaRepository<BoxInfoModel, Integer> {

    boolean existsBoxInfoModelByTMac(String TMac);

    BoxInfoModel queryByTMac(String TMac);

    @Transactional
    @Modifying
    @Query("update BoxInfoModel set " +
            "tokenNun =?1," +
            "tOnLong =  ?2," +
            "tOpenTims = ?3"+
            " where tMac =?4"
    )
    int update(Integer tokenNum,Integer tOnLong,Integer tOpenTims,String tMac);

}
